package com.yuyang.gulimall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author yu yang
 * @date 2023/1/12 -15:28
 */
@Configuration
public class RedissonConfig {

    @Bean
    RedissonClient redissonClient(@Value("${spring.redis.host}") String url){
        // 默认连接地址 127.0.0.1:6379
        //        RedissonClient redisson = Redisson.create();
        Config config = new Config();
        //redis://127.0.0.1:7181
        //可以用"rediss://"来启用 SSL 连接
        config.useSingleServer().setAddress("redis://"+url+":6379");
        return Redisson.create(config);
    }
}
